<%-- 
    Document   : SponsoredEvent
    Created on : 28-giu-2011, 12.53.51
    Author     : Stefano
--%>

<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@page import="ejb.SponsoredEvent"%>
<%@page import="java.util.LinkedList"%>
<%@page import="fql.FqlEvent"%>
<%@page import="java.util.List"%>
<%@page import="com.restfb.types.User"%>
<%@page import="com.restfb.FacebookClient"%>
<%@page import="com.restfb.DefaultFacebookClient"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
        <%@ include file="/style/styles.html" %>
        <%@ include file="/js/libraries.html" %>
    </head>
    <body onload="init()">
         <div id="wrapper">
            <%@ include file="/header.jsp" %>
            <h1>GESTIONE SPONSORIZZAZIONE EVENTI</h1>
            <%
            List<SponsoredEvent> alreadyInsert = new LinkedList<SponsoredEvent>();
            List<FqlEvent>  toInsert = new LinkedList<FqlEvent>();
            alreadyInsert = (List<SponsoredEvent>) request.getAttribute("alreadyInsert");
            toInsert = (List<FqlEvent>) request.getAttribute("toInsert");
            int credit = Integer.parseInt( (String)request.getAttribute("credit")); 
            %>

            <h3>Info generali<h3>

            <hr>
            Il tuo credito è : <%=credit%> impressions
            <hr>
            <br>
            <h3>Seleziona un evento che vuoi  sponsorizzare:</h3>

            <%
            if(toInsert.isEmpty()==false){  
            %> 

                <hr>
                <form onSubmit="return checkForm();" name="eventList" action= "/delo-war/IMDSponsoredEvent.jsp">

            <%
                for (FqlEvent fqle : toInsert) {
            %>

                    <br>
                    Evento: <%=fqle.getName()%>
                    <input type="radio" name="eid" checked="checked" value="<%=fqle.getEid()%>">
                    <input  type = "text" name = "<%=fqle.getEid()%>"  value="<%=fqle.getName()%>" style="visibility:hidden;"/>           


             <%       
             }
             %>

                    <br><br>
                    <div id="form-sponsor-date">
                        <label>Da</label><input size="10" type="text" class="datepicker" id="data-from" name="data-from" value=""/>
                        <label>A</label><input size="10" type="text" class="datepicker" id="data-to" name="data-to" value=""/>
                    </div>
                    <div>
                        <lable>Max Impressions</lable><input id="max-imp" name="max-imp" value="1000" type="text" size="10" />
                    </div>
                    <div><label>Tags</label><input type="text" id="tags-form" name="tags-form" value="Cultura" style="width: 250px;"/></div>
                    <div>
                        <input type="hidden" name="action" value="insert">
                    </div>
                    <input type="submit" name="Sponsorizza" value ="Sponsorizza"/>
                    <hr>

                </form>
            <%         
            }
            else {
            %>
                <hr>
                Non ci sono eventi che puoi sponsorizzare
                <hr>
            <%   
            }
            %>
            <br><br><br>                  
            <h3>Lista degli evnti sponsorizzati:</h3> 
            <%
            if(alreadyInsert.isEmpty()==false){
            %>    
                <hr>

    <!--            <form name="eventSponsored" action="delo-war/ActionSponsoredEventServlet">-->
                <% 
                for (SponsoredEvent fqle : alreadyInsert) {
                %>   
                    <br>
    <!--            <form name="eventList" action= "/delo-war/IMDSponsoredEventServlet">-->
                        Evento: <%=fqle.getName()%>
                        <a href="/delo-war/IMDSponsoredEventServlet?eid=<%=fqle.getEid()%>&action=modify">Modifica</a>
                        <a href="/delo-war/IMDSponsoredEventServlet?eid=<%=fqle.getEid()%>&action=delete">Elimina</a>

    <!--                    <input type="submit" name="action" value="Elimina"/>-->


    <!--                </form>-->
                <%  
                }
                %>
                <hr>
            <%
            }

            else{
            %>    
                <hr>
                Non hai ancora sponsorizzato nessun evento
                <hr>
            <%
            }
            %>
            </div>
        
    </body>
</html>
